﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;

namespace OmniKits.Windows.Design
{
    public class DragMoveThumb : Thumb
    {
        public DragMoveThumb()
        {
            this.Cursor = Cursors.SizeAll;

            this.DragDelta += OnDragDelta;
        }

        protected virtual void OnDragDelta(object sender, DragDeltaEventArgs e)
        {
            var target = this.DataContext as FrameworkElement;
            if (target == null) return;

            e.Handled = true;

            target.Move(new Point(e.HorizontalChange, e.VerticalChange));
        }
    }
}
